#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2024/1/28 17:14
# @Author : Yoin
from flask import Flask, render_template, request

# 使用flask框架
app = Flask(__name__)

# @app.route("/get/info", methods=["GET"])
# def get_register():
#     # 接受用户通过get方式发送的结果
#     print(request.args)
#     username = request.args.get("username")
#     password = request.args.get("password")
#     gender = request.args.get("gender")
#     hobby_list = request.args.getlist("hobby")
#     city = request.args.get("city")
#     return render_template("success.html")
#
#
# @app.route("/post/info", methods=["post"])
# def post_register():
#     # 接受用户通过post方式发送的结果
#     print(request.form)
#     username = request.form.get("username")
#     password = request.form.get("password")
#     gender = request.form.get("gender")
#     hobby_list = request.form.getlist("hobby")
#     city = request.form.get("city")
#     print(username, password, gender, hobby_list, city)
#     return render_template("success.html")


@app.route("/register", methods=["GET", "POST"])
def register():
    if request.method == "GET":  # 返回自己的页面
        return render_template("register.html")
    else:  # post请求
        username = request.form.get("username")
        password = request.form.get("password")
        gender = request.form.get("gender")
        hobby_list = request.form.getlist("hobby")
        city = request.form.get("city")
        print(username, password, gender, hobby_list, city)
        return render_template("success.html")


@app.route("/login", methods=["GET", "POST"])
def login():
    if request.method == "GET":
        return render_template("login.html")
    else:
        username = request.form.get("username")
        password = request.form.get("password")
        print(username, password)
        return render_template("success.html")


if __name__ == '__main__':
    # 更改主机名和端口号
    app.run(host="", port="8080")
